package com.learning.grpc.service;

import io.grpc.stub.ClientCalls;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.25.0)",
    comments = "Source: Learning.proto")
public final class LearningServiceGrpc {

  private LearningServiceGrpc() {}

  public static final String SERVICE_NAME = "com.learning.grpc.service.LearningService";

  // Static method descriptors that strictly reflect the proto.
  private static volatile io.grpc.MethodDescriptor<RequestService,
      ResponseService> getGetServiceMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "GetService",
      requestType = RequestService.class,
      responseType = ResponseService.class,
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
  public static io.grpc.MethodDescriptor<RequestService,
      ResponseService> getGetServiceMethod() {
    io.grpc.MethodDescriptor<RequestService, ResponseService> getGetServiceMethod;
    if ((getGetServiceMethod = LearningServiceGrpc.getGetServiceMethod) == null) {
      synchronized (LearningServiceGrpc.class) {
        if ((getGetServiceMethod = LearningServiceGrpc.getGetServiceMethod) == null) {
          LearningServiceGrpc.getGetServiceMethod = getGetServiceMethod =
              io.grpc.MethodDescriptor.<RequestService, ResponseService>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetService"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  RequestService.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  ResponseService.getDefaultInstance()))
              .setSchemaDescriptor(new LearningServiceMethodDescriptorSupplier("GetService"))
              .build();
        }
      }
    }
    return getGetServiceMethod;
  }

  private static volatile io.grpc.MethodDescriptor<ServiceInfo,
      ResponseService> getSaveServiceMethod;

  @io.grpc.stub.annotations.RpcMethod(
      fullMethodName = SERVICE_NAME + '/' + "SaveService",
      requestType = ServiceInfo.class,
      responseType = ResponseService.class,
      methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
  public static io.grpc.MethodDescriptor<ServiceInfo,
      ResponseService> getSaveServiceMethod() {
    io.grpc.MethodDescriptor<ServiceInfo, ResponseService> getSaveServiceMethod;
    if ((getSaveServiceMethod = LearningServiceGrpc.getSaveServiceMethod) == null) {
      synchronized (LearningServiceGrpc.class) {
        if ((getSaveServiceMethod = LearningServiceGrpc.getSaveServiceMethod) == null) {
          LearningServiceGrpc.getSaveServiceMethod = getSaveServiceMethod =
              io.grpc.MethodDescriptor.<ServiceInfo, ResponseService>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(SERVICE_NAME, "SaveService"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  ServiceInfo.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  ResponseService.getDefaultInstance()))
              .setSchemaDescriptor(new LearningServiceMethodDescriptorSupplier("SaveService"))
              .build();
        }
      }
    }
    return getSaveServiceMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static LearningServiceStub newStub(io.grpc.Channel channel) {
    return new LearningServiceStub(channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static LearningServiceBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    return new LearningServiceBlockingStub(channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static LearningServiceFutureStub newFutureStub(
      io.grpc.Channel channel) {
    return new LearningServiceFutureStub(channel);
  }

  /**
   */
  public static abstract class LearningServiceImplBase implements io.grpc.BindableService {

    /**
     */
    public void getService(RequestService request,
        io.grpc.stub.StreamObserver<ResponseService> responseObserver) {
      asyncUnimplementedUnaryCall(getGetServiceMethod(), responseObserver);
    }

    /**
     */
    public void saveService(ServiceInfo request,
        io.grpc.stub.StreamObserver<ResponseService> responseObserver) {
      asyncUnimplementedUnaryCall(getSaveServiceMethod(), responseObserver);
    }

    @Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getGetServiceMethod(),
            asyncUnaryCall(
              new MethodHandlers<
                RequestService,
                ResponseService>(
                  this, METHODID_GET_SERVICE)))
          .addMethod(
            getSaveServiceMethod(),
            asyncUnaryCall(
              new MethodHandlers<
                ServiceInfo,
                ResponseService>(
                  this, METHODID_SAVE_SERVICE)))
          .build();
    }
  }

  /**
   */
  public static final class LearningServiceStub extends io.grpc.stub.AbstractStub<LearningServiceStub> {
    private LearningServiceStub(io.grpc.Channel channel) {
      super(channel);
    }

    private LearningServiceStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected LearningServiceStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new LearningServiceStub(channel, callOptions);
    }

    /**
     */
    public void getService(RequestService request,
        io.grpc.stub.StreamObserver<ResponseService> responseObserver) {
      ClientCalls.asyncUnaryCall(
          getChannel().newCall(getGetServiceMethod(), getCallOptions()), request, responseObserver);
    }

    /**
     */
    public void saveService(ServiceInfo request,
        io.grpc.stub.StreamObserver<ResponseService> responseObserver) {
      ClientCalls.asyncUnaryCall(
          getChannel().newCall(getSaveServiceMethod(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class LearningServiceBlockingStub extends io.grpc.stub.AbstractStub<LearningServiceBlockingStub> {
    private LearningServiceBlockingStub(io.grpc.Channel channel) {
      super(channel);
    }

    private LearningServiceBlockingStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected LearningServiceBlockingStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new LearningServiceBlockingStub(channel, callOptions);
    }

    /**
     */
    public ResponseService getService(RequestService request) {
      return blockingUnaryCall(
          getChannel(), getGetServiceMethod(), getCallOptions(), request);
    }

    /**
     */
    public ResponseService saveService(ServiceInfo request) {
      return blockingUnaryCall(
          getChannel(), getSaveServiceMethod(), getCallOptions(), request);
    }

    public void saveService() {
    }
  }

  /**
   */
  public static final class LearningServiceFutureStub extends io.grpc.stub.AbstractStub<LearningServiceFutureStub> {
    private LearningServiceFutureStub(io.grpc.Channel channel) {
      super(channel);
    }

    private LearningServiceFutureStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @Override
    protected LearningServiceFutureStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new LearningServiceFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<ResponseService> getService(
        RequestService request) {
      return futureUnaryCall(
          getChannel().newCall(getGetServiceMethod(), getCallOptions()), request);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<ResponseService> saveService(
        ServiceInfo request) {
      return futureUnaryCall(
          getChannel().newCall(getSaveServiceMethod(), getCallOptions()), request);
    }
  }

  private static final int METHODID_GET_SERVICE = 0;
  private static final int METHODID_SAVE_SERVICE = 1;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final LearningServiceImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(LearningServiceImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @Override
    @SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_GET_SERVICE:
          serviceImpl.getService((RequestService) request,
              (io.grpc.stub.StreamObserver<ResponseService>) responseObserver);
          break;
        case METHODID_SAVE_SERVICE:
          serviceImpl.saveService((ServiceInfo) request,
              (io.grpc.stub.StreamObserver<ResponseService>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @Override
    @SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class LearningServiceBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    LearningServiceBaseDescriptorSupplier() {}

    @Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return LearningServiceProto.getDescriptor();
    }

    @Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("LearningService");
    }
  }

  private static final class LearningServiceFileDescriptorSupplier
      extends LearningServiceBaseDescriptorSupplier {
    LearningServiceFileDescriptorSupplier() {}
  }

  private static final class LearningServiceMethodDescriptorSupplier
      extends LearningServiceBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    LearningServiceMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (LearningServiceGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new LearningServiceFileDescriptorSupplier())
              .addMethod(getGetServiceMethod())
              .addMethod(getSaveServiceMethod())
              .build();
        }
      }
    }
    return result;
  }
}
